﻿1 	public int LockSeat(List<Seat> seats, int status)
2 	{
3 
4 		int result = -1;
5 
6 		//
7 		using (TransactionScope scope = 
8 				new TransactionScope(TransactionScopeOption.Required, 
9 									 new TransactionOptions
10			{
11				IsolationLevel = IsolationLevel.Snapshot
12			}))
13		{
14			using (var context = new BioBookingContext())
15			{
16				foreach (Seat s in seats)
17				{
18					try
19					{
20						EntitySeat eSeat = (from es in db.Seats
21											where es.id == s.SeatId && es.status == "0"   
22											select es).First();
23
24						eSeat.status = status.ToString();
25					}
26					catch (Exception e)
27					{
28						Console.WriteLine("Error: " + e);
29					}
30				}
31				result = db.SaveChanges();
32			}
33			scope.Complete();
34		}
35		return result;
36	}